using CfgTable;
using IQIGame.Onigao.Framework;
using IQIGame.Onigao.Game;

namespace IQIGame.Onigao.GamePlay
{
    public class UIN_SkillLvPreviewCell : UIBaseNode
    {
        #region Template Generate,don't modify
        protected class UIB_UIN_SkillLvPreviewCell
        {
            #region ObjectBinding Generate
            public IQIGame.Onigao.Framework.ExText textDes { protected set; get; }
            public IQIGame.Onigao.Framework.ExText textAddLv { protected set; get; }
            public IQIGame.Onigao.Framework.ExImage bg { protected set; get; }
            public UnityEngine.GameObject unlock { protected set; get; }
            public virtual void InitBinding(ObjectBinding __binding)
            {
                __binding.TryGetVariableValue<IQIGame.Onigao.Framework.ExText>("textDes", out var __tbv0);
                this.textDes = __tbv0;
                __binding.TryGetVariableValue<IQIGame.Onigao.Framework.ExText>("textAddLv", out var __tbv1);
                this.textAddLv = __tbv1;
                __binding.TryGetVariableValue<IQIGame.Onigao.Framework.ExImage>("bg", out var __tbv2);
                this.bg = __tbv2;
                __binding.TryGetVariableValue<UnityEngine.GameObject>("unlock", out var __tbv3);
                this.unlock = __tbv3;
            }
            #endregion ObjectBinding Generate 
        }
        #endregion Template Generate,don't modify

        #region fields



        #endregion fields

        #region properties

        protected UIB_UIN_SkillLvPreviewCell ui { get; set; }
        protected UIMsgDispatcher uiMsgDispatcher => this._msgDispatcher as UIMsgDispatcher;

        #endregion properties

        protected override void BeforeInit()
        {
            ui = new UIB_UIN_SkillLvPreviewCell();
            ui.InitBinding(this.csObjBind);
        }

        protected override void OnInit()
        {

        }

        protected override void OnShow()
        {

        }

        protected override void OnHide()
        {

        }

        /// <summary>
        /// 添加UGUI侦听
        /// </summary>
        protected override void AddUGUIListener()
        {

        }

        /// <summary>
        /// 添加全局侦听（MsgDispatcher）
        /// </summary>
        protected override void AddMsgListeners()
        {

        }

        protected override void OnDispose()
        {

        }

        #region methonds

        public void Show(int currentLev, CfgSkillLevel cfgSkillLevel)
        {
            int add = cfgSkillLevel.SkillLevel - 1;
            ui.textAddLv.text = add > 0 ? "+" + add : "" + add;
            ui.textDes.text = cfgSkillLevel.EffectText;

            bool isUnlock = currentLev >= cfgSkillLevel.SkillLevel;
            //ui.textAddLv.indexSwitchColor = isUnlock ? 1 : 0;
            //ui.textDes.indexSwitchColor = isUnlock ? 1 : 0;
            //ui.bg.indexSwitchSprite = isUnlock ? 1 : 0;
            ui.unlock.SetActive(isUnlock);
        }

        #endregion methonds
    }
}
